<?php
/**
 * Created by PhpStorm.
 * User: HouJie
 * Date: 2018-4-3
 * Time: 15:29
 */

namespace Bqdove;

use Bqdove\Container\Container;

class CacheManager
{
    protected static $default_store = 'file';

    /**
     * 采用静态方法调用时，直接从服务容器中获取对应的实例方法
     * @param $name
     * @param $arguments
     * @return mixed
     * @throws \Exception
     */
    public static function __callStatic($name, $arguments)
    {
        $app = static::resolveFacadeInstance();
        return call_user_func_array(array($app, $name), $arguments);
    }

    /**
     *
     * @param $store
     * @return mixed
     * @throws \Exception
     */
    public static function store($store)
    {
        return static::resolveFacadeInstance($store);
    }

    /**
     * 返回不同缓存驱动的实例
     * @param null $store
     * @return mixed
     * @throws \Exception
     */
    public static function resolveFacadeInstance($store = null)
    {
        $store = $store == null ? static::$default_store : $store;
        return Container::make($store);
    }
}

